import {
  Cell
} from "./cell";
import {
  Img,
  ImgType
} from "./img";

const TEXT = {

}

class Cloak extends Cell {
  // 初始化
  constructor(row, col) {
    super(row, col)

    this.isCloak = true // 遮挡块
    this.isMine = false
    this.value = null
    this.flag = null
    this.image = new Img(this.config, ImgType.block)
  }
  // 设置为雷
  setMine() {
    this.isMine = true
  }
  // 设置值
  setValue(val) {
    this.value = val
  }
  // 翻开
  show(color) {
    if (!this.isCloak) return false
    this.isCloak = false

    if (this.isMine) {
      this.image.set(ImgType.mine)
      if (color) {
        this.config.fill = 'red'
      }
      return true
    }
    let val = this.value
    if (val == null) this.image.set(ImgType.none)
    else if (val == 1) this.image.set(ImgType.one)
    else if (val == 2) this.image.set(ImgType.two)
    else if (val == 3) this.image.set(ImgType.three)
    else if (val == 4) this.image.set(ImgType.four)
    else if (val == 5) this.image.set(ImgType.five)
    else if (val == 6) this.image.set(ImgType.six)
    else if (val == 7) this.image.set(ImgType.seven)
    else if (val == 8) this.image.set(ImgType.eight)
    return false
  }
  // 插旗子
  setFlag() {
    this.flag = new Img(this.config, ImgType.flag)
    this.flag.setFlag()
  }
}

export default Cloak